home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / AWT / IMAGE / ImageWatched.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  1.3 KB  |  79 lines

  1. package sun.awt.image;
  2.  
  3. import java.awt.Image;
  4. import java.awt.image.ImageObserver;
  5. import java.util.Enumeration;
  6. import java.util.NoSuchElementException;
  7. import java.util.Vector;
  8.  
  9. public class ImageWatched {
  10.    protected Vector watchers;
  11.  
  12.    public synchronized void addWatcher(ImageObserver var1) {
  13.       if (var1 != null && !this.isWatcher(var1)) {
  14.          if (this.watchers == null) {
  15.             this.watchers = new Vector();
  16.          }
  17.  
  18.          this.watchers.addElement(var1);
  19.       }
  20.  
  21.    }
  22.  
  23.    public synchronized boolean isWatcher(ImageObserver var1) {
  24.       if (this.watchers != null && var1 != null) {
  25.          Vector var2 = this.watchers;
  26.          if (var2.indexOf(var1, 0) >= 0 || false) {
  27.             return true;
  28.          }
  29.       }
  30.  
  31.       return false;
  32.    }
  33.  
  34.    public synchronized void removeWatcher(ImageObserver var1) {
  35.       if (var1 != null && this.watchers != null) {
  36.          this.watchers.removeElement(var1);
  37.          Vector var2 = this.watchers;
  38.          if (var2.elementCount == 0) {
  39.             this.watchers = null;
  40.          }
  41.       }
  42.  
  43.    }
  44.  
  45.    public void newInfo(Image var1, int var2, int var3, int var4, int var5, int var6) {
  46.       if (this.watchers != null) {
  47.          Enumeration var7 = this.watchers.elements();
  48.          Vector var8 = null;
  49.  
  50.          while(var7.hasMoreElements()) {
  51.             ImageObserver var9;
  52.             try {
  53.                var9 = (ImageObserver)var7.nextElement();
  54.             } catch (NoSuchElementException var10) {
  55.                break;
  56.             }
  57.  
  58.             if (!var9.imageUpdate(var1, var2, var3, var4, var5, var6)) {
  59.                if (var8 == null) {
  60.                   var8 = new Vector();
  61.                }
  62.  
  63.                var8.addElement(var9);
  64.             }
  65.          }
  66.  
  67.          if (var8 != null) {
  68.             var7 = var8.elements();
  69.  
  70.             while(var7.hasMoreElements()) {
  71.                ImageObserver var12 = (ImageObserver)var7.nextElement();
  72.                this.removeWatcher(var12);
  73.             }
  74.          }
  75.       }
  76.  
  77.    }
  78. }
  79.